import {ADDCOUNTER, ADDTOCART} from './mutation-type'
export default {
		addCart(context, payload) {
				return new Promise((resolve, reject) => {
				payload.isChecked = true
				let oldProduct = context.state.cartList.find(item => item.iid === payload.iid)
				if(oldProduct){
					context.commit(ADDCOUNTER, oldProduct)
					resolve("商品数量+1")
				}else{
					payload.count = 1
					context.commit(ADDTOCART, payload)
					resolve("添加新商品成功")
				}
			})
			
		}
	}